package cn.doctorpda.conference.model;

import android.content.Context;

import org.json.JSONObject;

import cn.doctorpda.conference.MyApplication;
import cn.doctorpda.conference.config.AppConfig;
import cn.doctorpda.conference.config.NetConfig;
import cn.doctorpda.conference.localstore.ClientInfo;
import cn.doctorpda.conference.okhttp.OkHttpUtils;
import cn.doctorpda.conference.okhttp.callback.Callback;
import cn.doctorpda.conference.utils.AESUtil;

/**
 * Created by huangjinlong on 2016/5/19.
 */
public class GetSearchConModel implements IPostModel {

    Context context = MyApplication.getInstance();

    @Override
    public void postNetWorkStringData(String url, Callback callback, String... parameter) {
        JSONObject object = new JSONObject();

        try {
//            object.put("page", parameter[0]);
//            object.put("limit", parameter[1]);
            object.put("q", parameter[2]);//关键字
            object.put("type", parameter[3]);
            object.put("model", "all");
        } catch (Exception e) {
            e.printStackTrace();
        }
        String data = AESUtil.encrypt(object.toString(), AppConfig.AES_KEY);
        url = NetConfig.GET_SEARCH_ACTIVITY + "?source=con&app_key="+AppConfig.APP_KEY+"&client_id="+ ClientInfo.getClientId(context)+"&net=wifi&versionName=1.0&versionCode=1";
        OkHttpUtils.post()
                .url(url)
                .addParams("page",parameter[0])
                .addParams("limit",parameter[1])
                .addParams("data", data)
                .addParams("encrpt_flag", "1")
                .build()
                .execute(callback);
    }
}
